package com.xiangyun.xyojbackendjudgeservice.codesandbox;


import com.xiangyun.xyojbackendjudgeservice.codesandbox.impl.ExampleCodeSandBoxImpl;
import com.xiangyun.xyojbackendjudgeservice.codesandbox.impl.RemoteCodeSandBoxImpl;
import com.xiangyun.xyojbackendjudgeservice.codesandbox.impl.ThirdPartyCodeSandBoxImpl;

/**
 * 代码沙箱工厂，根据用户传入的字符串参数（沙箱类别）
 */
public class CodeSandBoxFactory {

    /**
     * 创建代码沙箱示例
     *
     * @param type（沙箱类型）
     * @return
     */
    public static CodeSandBox newInstance(String type) {
        switch (type) {
            case "remote":
                return new RemoteCodeSandBoxImpl();
            case "thirdParty":
                return new ThirdPartyCodeSandBoxImpl();
            default:
                return new ExampleCodeSandBoxImpl();

        }
    }
}
